#pragma once

#include <QObject>
#include <QGraphicsItemGroup>
#include "MyHandleItem.h"
#include "MyEllipseItem.h"

class MyGraphicsEllipsItem : public QObject, public QGraphicsItemGroup
{
	Q_OBJECT
public:
	MyGraphicsEllipsItem(QPointF* pos, QGraphicsItem *parent = nullptr);
	~MyGraphicsEllipsItem();

	virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;

	virtual QRectF boundingRect() const;

	void resizeItem(qreal x, qreal y, qreal width, qreal height);

	QRectF rect();

	QPoint leftTopPos();

	void finishCreate();

	int isFinishCreate();

protected:
	void mousePressEvent(QGraphicsSceneMouseEvent* event);

private:
	void initItem(QPointF* pos, QGraphicsItem* parent = nullptr);
	void initSlots();

private slots:
	void onReceivePosFromHandle();
	void onCircleMoved();

private:
	MyEllipseItem* m_pCircle = nullptr;
	MyHandleItem* m_pLeftTopHandle = nullptr;
	MyHandleItem* m_pRightTopHandle = nullptr;
	MyHandleItem* m_pLeftBottomHandle = nullptr;
	MyHandleItem* m_pRightBottomHandle = nullptr;
	int m_isFinishCreate = 0;
};
